<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>shardWorker - 非跨域 - shared1</title>
	</head>

	<body>
		<input type="button" value="点击发送消息" id="btn" />
		<script>
			const worker = new SharedWorker('./work.js')
			worker.port.onmessage = (e) => {
				console.log('receive message:', e.data)
			}

			const btn = document.querySelector('#btn')
			btn.addEventListener('click', (e) => {
				worker.port.postMessage('postMessage from shared1')
			})
		</script>
	</body>
</html>
